/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package managedbean.RawMaterialPurchase;

import java.util.List;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.event.ActionEvent;
import merlion.scm.rmpm.entity.RawMaterial;
import merlion.scm.rmpm.entity.Supplier;
import merlion.scm.rmpm.pojo.RankingRow;
import merlion.scm.rmpm.session.RawMaterialPurchaseSessionBeanLocal;

/**
 *
 * @author Kenn
 */
@ManagedBean(name = "rankingManagerBean")
@ViewScoped
public class SupplierRankingManagerBean {

    @EJB
    private RawMaterialPurchaseSessionBeanLocal rmpSessionBean;
    
    private RawMaterial rm;
    private String criteria;
    private List<RankingRow> rankings;
    
    //--------------------------------------------------------------------------
    //                            Constructor
    //--------------------------------------------------------------------------
    public SupplierRankingManagerBean() {
        rm = null;
    }
    
    //--------------------------------------------------------------------------
    //                          Manager Bean Methods
    //--------------------------------------------------------------------------
    
    public List<RawMaterial> getAllRawMaterial(){
        return rmpSessionBean.getAllRawMaterial();
    }
    
    public void rankSupplier(ActionEvent event){
        rankings = rmpSessionBean.rankSupplier(rm, criteria);
    }
    
    //--------------------------------------------------------------------------
    //                            Getter and Setter
    //--------------------------------------------------------------------------

    public RawMaterial getRm() {
        return rm;
    }

    public void setRm(RawMaterial rm) {
        this.rm = rm;
    }

    public String getCriteria() {
        return criteria;
    }

    public void setCriteria(String criteria) {
        this.criteria = criteria;
    }

    public List<RankingRow> getRankings() {
        return rankings;
    }

    public void setRankings(List<RankingRow> rankings) {
        this.rankings = rankings;
    }

}
